using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace CinemaLib
{
    /// <summary>
    /// Contains relevant informations about a show.
    /// </summary>
    [DataContract]
    public class Show
    {
        [DataMember]
        public int ID { get; private set; } //AAAY AHOY!
        [DataMember]
        public TimeSpan Length { get; set; }
        [DataMember]
        public DateTime StartTime { get; set; }
        [DataMember]
        public Movie Movie { get; set; }
        [DataMember]
        public Hall HallRoom { get; set; }
        [DataMember]
        public string Name { get; set; }
        [DataMember]
        public double Price { get; private set; }

        public Show(int _id, string _name, double _price, DateTime _starttime, TimeSpan _length, Hall _hallroom, Movie _movie)
        {
            ID = _id;
            Name = _name;
            Price = _price;
            StartTime = _starttime;
            Length = _length;
            HallRoom = _hallroom;
            Movie = _movie;
            if (!_hallroom.AddShow(this))
            {
                throw new FormatException("This time is invalid as there is an other movie running at that time!");
            }
        }

        public Show(string _name, double _price, DateTime _starttime, TimeSpan _length, Hall _hallroom, Movie _movie)
        {
            Name = _name;
            Price = _price;
            StartTime = _starttime;
            Length = _length;
            HallRoom = _hallroom;
            Movie = _movie;
            if (!_hallroom.AddShow(this))
            {
                throw new FormatException("This time is invalid as there is an other movie running at that time!");
            }
        }

        public Show(double _price, DateTime _starttime, TimeSpan _length, Hall _hallroom, Movie _movie)
        {
            Name = _movie.Name;
            Price = _price;
            StartTime = _starttime;
            Length = _length;
            HallRoom = _hallroom;
            Movie = _movie;
            if (!_hallroom.AddShow(this))
            {
                throw new FormatException("This time is invalid as there is an other movie running at that time!");
            }
        }
    }
}
